<template>
  <div class="Container">
    <div class="addInfo">
      <span> 标题:</span>
      <input
        type="text"
        v-model="title"
        placeholder="请输入标题"
        name=""
        id=""
      >
      <span> 运营商:</span>
      <el-select
        v-model="exchangeBannerId"
        placeholder="请选择"
      >
        <el-option
          v-for="item in ExchangeBannerList"
          :key="item.id"
          :label="item.name"
          :value="item.id"
        ></el-option>
      </el-select>
    </div>
    <quill-editor
      ref="myTextEditor"
      v-model.trim="text"
    ></quill-editor>
    <div
      class="oks"
      @click="isOk()"
    >确定</div>
  </div>
</template>


<script>
import { quillEditor } from "vue-quill-editor";
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
export default {
  data() {
    return {
      text: "",
      title: "",
      ExchangeBannerList: [],
      exchangeBannerId: ""
    };
  },
  components: {
    quillEditor
  },
  created() {
    this.getExchangeBanner();
  },
  methods: {
    //获取运营商名称
    getExchangeBanner() {
      let url = "/exchangeBanner/getList";
      let params = {
        pageNum: "",
        pageSize: ""
      };
      this.httpPost(url, params, res => {
        if (res.code == 200) {
          this.ExchangeBannerList = res.data.list;
        } else {
          console.log("查询失败");
        }
      });
    },
    isOk() {
      let self = this;
      if (!this.title) {
        this.$message({
          message: "请输入标题",
          type: "warning"
        });
        return;
      }
      if (!this.exchangeBannerId) {
        this.$message({
          message: "请选择运营商",
          type: "warning"
        });
        return;
      }
      if (!this.text) {
        this.$message({
          message: "请输入内容",
          type: "warning"
        });
        return;
      }
      let url = "/exchangeCourse/addOne";
      this.httpPost(
        url,
        {
          title: this.title,
          text: this.text,
          exchangeBannerId : this.exchangeBannerId
        },
        res => {
          if (res.code == 200) {
            self.$message({
              message: "操作成功",
              type: "success"
            });
            setTimeout(() => {
              self.$router.go(-1);
            }, 1000);
          }
        }
      );
    }
  }
};
</script>

<style lang="scss" scoped>
.Container {
  overflow: hidden;
}
.addInfo {
  margin-top: 20px;
  margin-bottom: 20px;
}
input {
  width: 280px;
  height: 35px;
  margin: 2px 0;
}
.oks {
  margin: 20px auto;
  width: 100px;
  text-align: center;
  background: #409eff;
  line-height: 40px;
  color: #fff;
  border-radius: 5px;
  cursor: pointer;
}
</style>
<style>
.ql-editor {
  min-height: 300px;
}
.ql-video {
  display: none !important;
}
</style>
